﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using MixScriptWeb.control;
using MixScriptWeb.Share;
using MixScript.BLL;
using MixScriptWeb.AppCode.gjips;
using MixScript.BLL.MM;

namespace MixScriptWeb.Jideco
{
    public partial class fPOInq2 : cCommonWeb, IMIxCommon
    {
        private static DataTable dt;
        private static DataTable dtprint;
        private static SortDirection sd;
        private static cRefGjips oReff;
        private const string stblname = "tb_pomst";

        private static string scustid, ddate = "";

        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (!Page.IsPostBack)
                {
                    addFindClickAttribute(this, new MixScriptTB[] { txtCuid }, new string[] { "SRCCUST" });
                    //txtItNo.ReadOnly = true;
                    //  setSortExpression(gvdetail, new string[] { "banknum", "bankname", "address", "city", "country", "ac" });


                    //txtcustid.Tbx.Attributes.Add("readonly", "readonly");
                    // addRead(new MixScriptTB[] { txtcustid });
                    txtDate1.CssClass += " ritonli";
                    //string[] sheadertext = new string[] { "Case No.", "Sales Slip No.", "Customer Type", "Customer Code", "Delivery Place", "Addressee", "Delivery Date", "Customer PO. No.", "Customer Part No.", "Part No.", "Packing Quantity", "Contract Unit Code", "Order No.", "Shipping Date" };
                    string[] sheadertext = new string[] { "date", "delivery No", "Customer", "Qty", "Unit" };
                    string[] sdatavalue = new string[] { "dtcreated", "delno", "bpidnm", "totqty", "totuom" };
                    //string[] sdatavalue = new string[] { "pkno", "saslno", "cuidbc", "cuid", "cuiddvlc", "cuidadlc", "dvdt", "cuslno", "cuitno", "oaitno", "pkqt", "tdms", "cuod", "fpdt" };
                    initGvColumn(gvdetail, sheadertext, sdatavalue, new int[] { 0}, "{0:dd-MM-yyyy}");
     
                }
                mn = (MainMenu)this.Master;
                hideStatusBar();
                // oReff = new cReferences();
                // if(gvdetail.Rows.Count>0)
            }
            catch (Exception)
            {
                
                throw;
            }
        }

        protected void btnFind_Click(object sender, EventArgs e)
        {
            try
            {
                oReff = new cRefGjips(); //new cUserManagement();
                dt = new DataTable();
                Control[] ctl = new Control[] { txtDelNo,txtCuid,null,null,txtDate1};
                if (oReff.getInquiry(ref dt, genInqParam(ctl), stblname, out errMsg))
                {

                }
                else
                {
                    ShowStatusBar("Record Not Found", msgType.msgError);
                }
                bindGridview(gvdetail, dt);


            }
            catch (Exception)
            {
                
                throw;
            }
        }

        #region IMIxCommon Members

        public bool isvalid()
        {
            throw new NotImplementedException();
        }

        #endregion

        protected void btnClear_Click(object sender, EventArgs e)
        {
            try
            {
                txtDate1.Text = "";
                clearMixTB(new MixScriptTB[]{txtCuid,txtDelNo});


            }
            catch (Exception ex)
            {

                throw;
            }
        }

        protected void gvdetail_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                //txtPartno.Text = gvdetail.SelectedRow.Cells[0].Text;
                string spono = gvdetail.SelectedRow.Cells[2].Text;
               cPO oPO = new cPO();
                dtprint= new DataTable();

                dtprint = oPO.getPOList(delno);
                Response.Write("<script>alert('sf');</script>");


            }
            catch (Exception ex)
            {

                throw;
            }

        }

        protected void gvdetail_Sorting(object sender, GridViewSortEventArgs e)
        {

        }

        protected void gvdetail_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            try
            {

                if (e.Row.RowType == DataControlRowType.DataRow)
                {
                    LinkButton lb = (LinkButton)e.Row.FindControl("LinkButton1");
                    string sid = e.Row.Cells[2].Text;
                    lb.OnClientClick = "printdn('../print/rptid-1,dnno-"+sid+",dl.html')";
                }


            }
            catch (Exception ex         )
            {

                ShowStatusBar(ex.Message);
            }
        }

        protected void gvdetail_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {

        }

        protected void LinkButton2_Click(object sender, EventArgs e)
        {

        }
    }
}